package com.zzptc.zzsgz.bdsjws.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.vo.Contact;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/6/13.
 */

public class SosAdapter  extends RecyclerView.Adapter<SosAdapter.MyAdapter>{
    List<Contact> list;
    public SosAdapter(List<Contact> list){
        this.list=list;

    }
    @Override
    public MyAdapter onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(MyApplication.getContext()).inflate(R.layout.sos_contact_item,parent,false);
        MyAdapter myAdapter=new MyAdapter(view);

        return myAdapter;
    }

    @Override
    //绑定数据
    public void onBindViewHolder(MyAdapter holder, int position) {
        Contact contact=list.get(position);
        holder.tv_sosname.setText(contact.getName());
        holder.tv_sosid.setText(contact.getTelnum());
        holder.tv_sosadree.setText(contact.getAddress());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyAdapter extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_sosname)
        TextView tv_sosname;
        @BindView(R.id.tv_sosid)
        TextView tv_sosid;
        @BindView(R.id.tv_sosadree)
        TextView tv_sosadree;
        public MyAdapter(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
